package br.com.Servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.json.simple.JSONObject;

import br.com.Dao.EnderecoDao;
import br.com.Dao.PaginaDao;
import br.com.Modelo.Endereco;

/**
 * Servlet implementation class validperfil
 */
@WebServlet("/validperfil")
public class validperfil extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public validperfil() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		System.out.println("sdasdasdaaa");
		 PrintWriter out= response.getWriter();  
	     JSONObject json = new JSONObject();  
	     System.out.println(request.getParameter("name"));
         PaginaDao dao = new PaginaDao();
         if(request.getParameter("name").length() >= 6){
         
         if(dao.isPaginaEqual(request.getParameter("name")) == true){	        
	        json.put("valid", false);
	        
         }else{
            json.put("valid", true);
        	 
         }
         
         out.print(json); 
         }
       
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		System.out.println("sdasdasd");
	}

}
